feat: Add dynamic toggle to the hero CTA button when logged in#16
feat: Add dynamic toggle to the hero CTA button when logged in#16AndyVale wants to merge 1 commit intoalphaonelabs:mainfrom
Conversation
WalkthroughAdded a dynamically updating hero call-to-action element that reflects authentication state. The hero CTA destination and label adjust based on whether a user is logged in (checked via Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes 🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@public/index.html`:
- Around line 169-182: updateHeroCta duplicates the token/user lookup logic in
updateNav; extract that logic into a shared helper (e.g., getAuthState or
resolveAuthState) that returns { token, user, isAuthenticated } and call it from
both updateHeroCta and updateNav so both UI pieces use the same source of truth;
updateHeroCta to read isAuthenticated (or token/user) from the helper and then
set heroCta.href/textContent accordingly, removing the duplicated
localStorage/JSON.parse code.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository: alphaonelabs/coderabbit/.coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
Run ID: de1d139e-662c-4545-a13b-eb376871ac11
📒 Files selected for processing (1)
public/index.html
Abstract
Hi, this PR introduces a minor but important UX improvement to the homepage.
Previously, the main CTA (call-to-action) button in the
Herosection always prompted the user to "Join Free" and directed them to the registration page, even if they were already authenticated.This PR fixes that by dynamically updating the button's text and destination based on the user's login state.
Changes
updateHeroCta()function that checkslocalStoragefor the activeedu_tokenandedu_user./dashboard.html./login.html?tab=register.logout()action.update_button.mp4
Impact
Improves the frontend navigation flow for returning users by allowing them to jump straight into their dashboard directly from the hero banner, rather than manually navigating through the authentication pages. No backend or API changes were required.
Purpose
Add dynamic hero CTA button behavior that adapts based on user authentication state, improving navigation flow for both new and returning users on the landing page.
Key Changes
/dashboard.html/login.html?tab=registerlogout()function to reset the CTA when users sign outlocalStoragekeys (edu_tokenandedu_user) to determine authentication statusImpact